package top.xiangqifu.springboot2.user.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import top.xiangqifu.springboot2.user.vo.UserInfo;

import java.io.Serializable;

/**
 * 用户信息表
 *
 * @author 向启福
 */
@TableName(value = "tb_user")
@ApiModel(value = "用户信息" , description = "用户信息应答对象")
@Data
public class TbUser implements Serializable {

    private static final long serialVersionUID = 1L;
    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "主键",example = "1")
    @ApiParam(hidden = false)
    private Integer uid;
    @ApiModelProperty(value = "登录用户名",example = "admin")
    @ApiParam(hidden = false)
    private String username;
    @ApiModelProperty(value = "登录密码",example = "1")
    @ApiParam(hidden = false)
    private String password;
    @TableField(updateStrategy = FieldStrategy.NEVER)
    @ApiModelProperty(value = "密码盐",example = "1")
    @ApiParam(hidden = false)
    private String salt;
    @TableField(updateStrategy = FieldStrategy.NEVER)
    @ApiModelProperty(value = "用户鉴权id",example = "1")
    @ApiParam(hidden = false)
    private String accessId;
    @TableField(updateStrategy = FieldStrategy.NEVER)
    @ApiModelProperty(value = "用户鉴权key",example = "1")
    @ApiParam(hidden = false)
    private String accessKey;
    @ApiModelProperty(value = "用户角色",example = "1")
    @ApiParam(hidden = false)
    private Integer role;
    @TableLogic
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    @ApiModelProperty(value = "逻辑删除标记",example = "1")
    @ApiParam(hidden = false)
    private String deleted;
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    @ApiModelProperty(value = "注册时间",example = "2023-11-29 19:06:06")
    @ApiParam(hidden = false)
    private java.util.Date lastupdate;

    @TableField(exist = false)
    public UserInfo userInfo;
    public TbUser viewData(){
        TbUser user=new TbUser();
        user.setUid(this.getUid());
        user.setUsername(this.getUsername());
        user.setAccessId(this.getAccessId());
        user.setAccessKey(this.getAccessKey());
        user.setLastupdate(this.getLastupdate());
        return user;
    }

}
